
// Open MoneySpinner Suite v1
// An open source business management software system written in Java and MySQL
// Recommended IDE is NetBeans IDE 7.0.1
// Support Web Site: http://www.milliscript.com
//
// Copyright (C) 2014, Abiodun Aremu, Ibadan/NIGERIA.
// Open MoneySpinner Suite is distributed under the terms of the Apache License version 2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/*
 * LoginRegistration.java
 *
 * Created on Jan 25, 2011, 1:04:48 AM
 */

package openmoneyspinnersuite;

/**
 *
 * @author Abiodun Aremu
 */
import javax.swing.*;
import java.sql.*;

final class LoginRegistration extends javax.swing.JInternalFrame {
    Systems systems=new Systems();
    PreparedStatement statement;
    ResultSet result;
    Thread processThread=new Thread();
    Thread titleThread=new Thread();

    /** Creates new form LoginRegistration */
     LoginRegistration() {
        initComponents();
            /* Execute submit thread */
            processThread=new Thread(new Runnable() {
                public void run() {
                disableControls();
                resetFields();
                }
            });
            titleThread=new Thread(new Runnable() {
                public void run() {
                    while(processThread.isAlive())setProcessingTitle(titleThread);
                    enableControls();
                    System.out.println("viewItemCategoryThread stopped runing.");
                }
            });
            processThread.start();
            titleThread.start();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        employeeIDLabel = new javax.swing.JLabel();
        employeeIDComboBox = new javax.swing.JComboBox();
        usernameLabel = new javax.swing.JLabel();
        usernameTextField = new javax.swing.JTextField();
        passwordLabel = new javax.swing.JLabel();
        jPasswordField2 = new javax.swing.JPasswordField();
        systemLabel = new javax.swing.JLabel();
        systemComboBox = new javax.swing.JComboBox();
        registerButton = new javax.swing.JButton();
        passwordLabel1 = new javax.swing.JLabel();
        jPasswordField1 = new javax.swing.JPasswordField();
        cancelButton = new javax.swing.JButton();
        passwordLabel2 = new javax.swing.JLabel();
        jChatAliasTextField = new javax.swing.JTextField();

        setClosable(true);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(openmoneyspinnersuite.OpenMS_Finance_App.class).getContext().getResourceMap(LoginRegistration.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setFrameIcon(resourceMap.getIcon("Form.frameIcon")); // NOI18N
        setName("Form"); // NOI18N
        setVisible(true);

        employeeIDLabel.setFont(resourceMap.getFont("employeeIDLabel.font")); // NOI18N
        employeeIDLabel.setText(resourceMap.getString("employeeIDLabel.text")); // NOI18N
        employeeIDLabel.setName("employeeIDLabel"); // NOI18N

        employeeIDComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- Select --", "Item 2", "Item 3", "Item 4" }));
        employeeIDComboBox.setName("employeeIDComboBox"); // NOI18N
        employeeIDComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                employeeIDComboBoxActionPerformed(evt);
            }
        });

        usernameLabel.setFont(resourceMap.getFont("usernameLabel.font")); // NOI18N
        usernameLabel.setText(resourceMap.getString("usernameLabel.text")); // NOI18N
        usernameLabel.setName("usernameLabel"); // NOI18N

        usernameTextField.setText(resourceMap.getString("usernameTextField.text")); // NOI18N
        usernameTextField.setName("usernameTextField"); // NOI18N
        usernameTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                usernameTextFieldActionPerformed(evt);
            }
        });
        usernameTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                usernameTextFieldKeyTyped(evt);
            }
        });

        passwordLabel.setFont(resourceMap.getFont("passwordLabel.font")); // NOI18N
        passwordLabel.setText(resourceMap.getString("passwordLabel.text")); // NOI18N
        passwordLabel.setName("passwordLabel"); // NOI18N

        jPasswordField2.setText(resourceMap.getString("jPasswordField2.text")); // NOI18N
        jPasswordField2.setName("jPasswordField2"); // NOI18N
        jPasswordField2.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jPasswordField2KeyTyped(evt);
            }
        });

        systemLabel.setFont(resourceMap.getFont("systemLabel.font")); // NOI18N
        systemLabel.setText(resourceMap.getString("systemLabel.text")); // NOI18N
        systemLabel.setName("systemLabel"); // NOI18N

        systemComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- Select --", "Finance", "Finance +", "HR", "Inventory", "Inventory +", "View +", "Pay Roll", "Pay Roll +", "Purchase", "Purchase +", "Student +", "Sales", "Sales +", "Admin" }));
        systemComboBox.setToolTipText(resourceMap.getString("systemComboBox.toolTipText")); // NOI18N
        systemComboBox.setName("systemComboBox"); // NOI18N

        registerButton.setFont(resourceMap.getFont("registerButton.font")); // NOI18N
        registerButton.setIcon(resourceMap.getIcon("registerButton.icon")); // NOI18N
        registerButton.setText(resourceMap.getString("registerButton.text")); // NOI18N
        registerButton.setName("registerButton"); // NOI18N
        registerButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                registerButtonActionPerformed(evt);
            }
        });

        passwordLabel1.setFont(resourceMap.getFont("passwordLabel1.font")); // NOI18N
        passwordLabel1.setText(resourceMap.getString("passwordLabel1.text")); // NOI18N
        passwordLabel1.setName("passwordLabel1"); // NOI18N

        jPasswordField1.setName("jPasswordField1"); // NOI18N
        jPasswordField1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jPasswordField1KeyTyped(evt);
            }
        });

        cancelButton.setFont(resourceMap.getFont("cancelButton.font")); // NOI18N
        cancelButton.setIcon(resourceMap.getIcon("cancelButton.icon")); // NOI18N
        cancelButton.setText(resourceMap.getString("cancelButton.text")); // NOI18N
        cancelButton.setName("cancelButton"); // NOI18N
        cancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelButtonActionPerformed(evt);
            }
        });

        passwordLabel2.setFont(resourceMap.getFont("passwordLabel2.font")); // NOI18N
        passwordLabel2.setText(resourceMap.getString("passwordLabel2.text")); // NOI18N
        passwordLabel2.setName("passwordLabel2"); // NOI18N

        jChatAliasTextField.setName("jChatAliasTextField"); // NOI18N
        jChatAliasTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jChatAliasTextFieldActionPerformed(evt);
            }
        });
        jChatAliasTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jChatAliasTextFieldKeyTyped(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(systemLabel)
                        .addGap(68, 68, 68)
                        .addComponent(systemComboBox, 0, 209, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addComponent(passwordLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(61, 61, 61)
                                .addComponent(jChatAliasTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 207, Short.MAX_VALUE))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addComponent(passwordLabel)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jPasswordField2, javax.swing.GroupLayout.DEFAULT_SIZE, 206, Short.MAX_VALUE)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(registerButton)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(cancelButton)))))
                        .addGap(13, 13, 13))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(passwordLabel1, javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addComponent(usernameLabel)
                                .addGap(62, 62, 62)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(usernameTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 206, Short.MAX_VALUE)
                                    .addComponent(jPasswordField1, javax.swing.GroupLayout.DEFAULT_SIZE, 206, Short.MAX_VALUE))))
                        .addGap(13, 13, 13))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(employeeIDLabel)
                        .addGap(44, 44, 44)
                        .addComponent(employeeIDComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(144, Short.MAX_VALUE))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(employeeIDLabel)
                    .addComponent(employeeIDComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(usernameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(usernameLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(passwordLabel1)
                    .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(passwordLabel)
                    .addComponent(jPasswordField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(passwordLabel2)
                    .addComponent(jChatAliasTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(12, 12, 12)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(systemLabel)
                    .addComponent(systemComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 59, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cancelButton, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(registerButton, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void registerButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_registerButtonActionPerformed
        // TODO add your handling code here:
        if(employeeIDComboBox.getSelectedItem().equals("-- Select --"))
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Select Employee ID ","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }
        if(usernameTextField.getText().trim().isEmpty())
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Enter Employee Username ","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }
        if(String.valueOf(jPasswordField1.getPassword()).trim().isEmpty())
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Enter Employee Password ","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }
        if(String.valueOf(jPasswordField2.getPassword()).trim().isEmpty())
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Confirm Password ","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }
        if(jChatAliasTextField.getText().trim().isEmpty())
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please enter a chat alias","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }
        if(systemComboBox.getSelectedItem().equals("-- Select --"))
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Select Authorized System ","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }
        if(!String.valueOf(jPasswordField2.getPassword()).trim().equals(String.valueOf(jPasswordField1.getPassword()).trim()))
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Passwords Did Not Match \n Please Re-enter Password","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }
        if(systemComboBox.getSelectedItem().equals("Pay Roll")||systemComboBox.getSelectedItem().equals("Pay Roll +")||systemComboBox.getSelectedItem().equals("HR")
                ||systemComboBox.getSelectedItem().equals("Sales")||systemComboBox.getSelectedItem().equals("Sales +")
                ||systemComboBox.getSelectedItem().equals("Inventory")||systemComboBox.getSelectedItem().equals("Inventory +")
                ||systemComboBox.getSelectedItem().equals("Purchase")||systemComboBox.getSelectedItem().equals("Purchase +"))
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"This version of Milliscript MoneySpinner does not have the selected platform installed","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }
        else
        {
            /* Execute submit thread */
            processThread=new Thread(new Runnable() {
                public void run() {
                disableControls();
                submitData();
                resetFields();
                }
            });
            titleThread=new Thread(new Runnable() {
                public void run() {
                    while(processThread.isAlive())setProcessingTitle(titleThread);
                    enableControls();
                    System.out.println("viewItemCategoryThread stopped runing.");
                }
            });
            processThread.start();
            titleThread.start();
        }
    }//GEN-LAST:event_registerButtonActionPerformed

    private void setProcessingTitle(Thread thread)
    {
        try{
            this.setTitle("::. New System User - Processing Request");
            thread.sleep(500);
            this.setTitle("::. New System User - Processing Request.");
            thread.sleep(500);
            this.setTitle("::. New System User - Processing Request..");
            thread.sleep(500);
            this.setTitle("::. New System User - Processing Request...");
            thread.sleep(500);
        }catch(Exception e){System.out.println("Title thread"+e);}
    }
    
    private void employeeIDComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_employeeIDComboBoxActionPerformed
        // TODO add your handling code here:
        String employeeID=employeeIDComboBox.getSelectedItem().toString();
        if(employeeID.equals("-- Select --"))
        {
             /* Execute submit thread */
            processThread=new Thread(new Runnable() {
                public void run() {
                disableControls();
                resetEmployeeID();
                resetFields();
                }
            });
            titleThread=new Thread(new Runnable() {
                public void run() {
                    while(processThread.isAlive())setProcessingTitle(titleThread);
                    enableControls();
                    System.out.println("NewUserThread stopped runing.");
                }
            });
            processThread.start();
            titleThread.start();
        }
        else            
        {
            String employeeName=systems.getValue(OpenMSApp.Database_A,"Select * from Employee where cEmployeeID= '"+employeeID+"'","vFirstName").trim()+" "+
                        systems.getValue(OpenMSApp.Database_A,"Select * from Employee where cEmployeeID= '"+employeeID+"'","vMiddleName").trim()+" "+
                        systems.getValue(OpenMSApp.Database_A,"Select * from Employee where cEmployeeID= '"+employeeID+"'","vlastName").trim();
 
            setTitle("::. New System User ( "+employeeName+" )");
        }
            

    }//GEN-LAST:event_employeeIDComboBoxActionPerformed

    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
        
        if(processThread.isAlive())
        {
            try{
                processThread.stop();
                titleThread.stop();
                System.out.println("Threads successfully stopped.");
            }catch(Exception e){System.out.println("Thread stopping error: "+e);}
            this.setTitle("::. New System User");
            enableControls();
        }
        else
        this.dispose();
    }//GEN-LAST:event_cancelButtonActionPerformed

    private void usernameTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_usernameTextFieldActionPerformed
        // TODO add your handling code here:

    }//GEN-LAST:event_usernameTextFieldActionPerformed

    private void usernameTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_usernameTextFieldKeyTyped
        // TODO add your handling code here:
        String value=usernameTextField.getText();
        if(value.length()>9)
        {
        JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Maximum Number of Character (10) Exceeded ","ERROR !",JOptionPane.ERROR_MESSAGE);
        String newValue=String.copyValueOf(value.toCharArray(),0, 9);
        usernameTextField.setText(newValue);
        }
    }//GEN-LAST:event_usernameTextFieldKeyTyped

    private void jPasswordField1KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jPasswordField1KeyTyped
        // TODO add your handling code here:
        String value=String.valueOf(jPasswordField1.getPassword()).trim();
        if(value.length()>9)
        {
        JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Maximum Number of Character (10) Exceeded ","ERROR !",JOptionPane.ERROR_MESSAGE);
        String newValue=String.copyValueOf(value.toCharArray(),0, 9);
        jPasswordField1.setText(newValue);
        }
    }//GEN-LAST:event_jPasswordField1KeyTyped

    private void jPasswordField2KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jPasswordField2KeyTyped
        // TODO add your handling code here:
        String value=String.valueOf(jPasswordField2.getPassword()).trim();
        if(value.length()>9)
        {
        JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Maximum Number of Character (10) Exceeded ","ERROR !",JOptionPane.ERROR_MESSAGE);
        String newValue=String.copyValueOf(value.toCharArray(),0, 9);
        jPasswordField2.setText(newValue);
        }
    }//GEN-LAST:event_jPasswordField2KeyTyped

private void jChatAliasTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jChatAliasTextFieldActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jChatAliasTextFieldActionPerformed

private void jChatAliasTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jChatAliasTextFieldKeyTyped
// TODO add your handling code here:
}//GEN-LAST:event_jChatAliasTextFieldKeyTyped

     void submitData()
    {
        //Connect.createMSSQLConnection();
        Connect.changeDB(OpenMSApp.Database_A);
        statement=Connect.createStatement(Connect.procInit+"  prnInsLogin"+Connect.procInitStart+"?,?,?,?,?"+Connect.procInitEnd);
         try{
                    statement.setString(1,String.valueOf(employeeIDComboBox.getSelectedItem()).trim());
                    statement.setString(2,usernameTextField.getText().trim());
                    statement.setString(3,String.valueOf(jPasswordField1.getPassword()).trim());
                    statement.setString(4,String.valueOf(systemComboBox.getSelectedItem()).trim());
                    statement.setString(5,jChatAliasTextField.getText().trim());

            }
            catch(Exception e)
            {
                JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Username already exist ","ERROR !",JOptionPane.ERROR_MESSAGE);
                System.out.println("LoginRegistration.submitData() gave error ! "+e);
            }
        Connect.alert="Y";
        Connect.executeUpdateStatement(statement);
        Connect.closeConnection();
    }
     void resetFields()
    {
        usernameTextField.setText("");
        jChatAliasTextField.setText("");
        jPasswordField1.setText("");
        jPasswordField2.setText("");
        systemComboBox.setSelectedItem("-- Select --");
        resetEmployeeID();
    }
     private void disableControls()
     {
        usernameTextField.setEnabled(false);
        jChatAliasTextField.setEnabled(false);
        jPasswordField1.setEnabled(false);
        jPasswordField2.setEnabled(false);
        systemComboBox.setEnabled(false);
        employeeIDComboBox.setEnabled(false);
        systemComboBox.setEnabled(false);
     }
     private void enableControls()
     {
        usernameTextField.setEnabled(true);
        jChatAliasTextField.setEnabled(true);
        jPasswordField1.setEnabled(true);
        jPasswordField2.setEnabled(true);
        systemComboBox.setEnabled(true);
        employeeIDComboBox.setEnabled(true);
        systemComboBox.setEnabled(true);
        this.setTitle("::. New System User");
     }
     void reset()
    {
        resetFields();
    }
     void resetCombo()
    {
        resetEmployeeID();
    }
     void resetEmployeeID()
    {
        String[] employeeID=systems.getTableDataArray(OpenMSApp.Database_A,"Employee",1);
        employeeID[0]="-- Select --";
        employeeIDComboBox.setModel(new DefaultComboBoxModel(employeeID));
    }


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton cancelButton;
    private javax.swing.JComboBox employeeIDComboBox;
    private javax.swing.JLabel employeeIDLabel;
    private javax.swing.JTextField jChatAliasTextField;
    private javax.swing.JPasswordField jPasswordField1;
    private javax.swing.JPasswordField jPasswordField2;
    private javax.swing.JLabel passwordLabel;
    private javax.swing.JLabel passwordLabel1;
    private javax.swing.JLabel passwordLabel2;
    private javax.swing.JButton registerButton;
    private javax.swing.JComboBox systemComboBox;
    private javax.swing.JLabel systemLabel;
    private javax.swing.JLabel usernameLabel;
    private javax.swing.JTextField usernameTextField;
    // End of variables declaration//GEN-END:variables

}
